package com.jing.countmvvmdemo.viewModel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.jing.countmvvmdemo.model.CountModel;
public class CountViewModel extends ViewModel {
    CountModel countModel;
    MutableLiveData<Integer> count;
    public CountViewModel(){
        countModel=new CountModel(0);
        count=new MutableLiveData<>(countModel.getCount());
    }
    public LiveData<Integer> getCount(){
        return count;
    }
    public void increment(){
        countModel.increment();
        count.setValue(countModel.getCount());
    }
    public void decrement(){
        countModel.decrement();
        count.setValue(countModel.getCount());
    }
}
